<template>
  <svg
    :class="svgClass"
    v-bind="$attrs"
    :style="{ color: color,width: width, height: height }"
  >
    <use :xlink:href="iconName" />
  </svg>
</template>

<script setup lang="ts">
import { computed } from 'vue'

const props = defineProps({
  iconClass: {
    type: String,
    required: true
  },
  color: {
    type: String,
    default: ''
  },
  width: {
    type: String,
    default: '20px'
  },
  height: {
    type: String,
    default: '20px'
  }

})

const iconName = computed(() => `#icon-${props.iconClass}`)
const svgClass = computed(() => {
  if (props.iconClass) {
    return `svg-icon icon-${props.iconClass}`
  }
  return 'svg-icon'
})
</script>

<style lang="scss" scoped>
.svg-icon{
  // width: 20px;
  // height: 20px;
  fill: currentColor;
  vertical-align: middle;
}
</style>
